#pragma once

#include <Window.h>
#include <vector>
#include <functional>

using std::vector;
typedef std::basic_string<TCHAR> generic_string;


struct FoundInfo
{
    FoundInfo(int start, int end, int lineNumber, const TCHAR* line = TEXT(""), const TCHAR* fullPath = TEXT(""))
        :_start(start), _end(end), _lineNumber(lineNumber), _line(line), _fullPath(fullPath){};
    int _start;
    int _end;
    int _lineNumber;
    generic_string _fullPath;
    generic_string _line;

//    SearchResultMarking _markers;    
};

typedef std::function<void()> FindCallback;

class Finder
{
public:
    Finder(HWND pScintillaPtr);
    ~Finder();

    void FindServerCalls(FindCallback callback);    

    bool DoSearch(const char* txtToFind,int fromPos, int endPos);

    const FoundInfo& GetLastFoundInfo() const;

protected:
    LRESULT execute(UINT Msg, WPARAM wParam=0, LPARAM lParam=0) const;

private:
    void initSearch();

private:
    HWND _pScintillaPtr;
    std::vector<FoundInfo> _results;
    FoundInfo* _lastFoundInfo;
};